#pragma once

#include <QtCore/QAbstractItemModel>

#include "task.hpp"
#include "scheduler.hpp"




namespace services
{
	class SERVICES_API TaskModel
		: public QAbstractTableModel
	{
		//Q_OBJECT

	public:

		TaskModel(scheduler::ptr s, QObject* parent);

		/**
		 * Queries all tasks from the stored scheduler and
		 * informs any attached view about changes.
		 */
		void update();

		virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
		virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
		virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
		virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;

	private:

		scheduler::ptr                 m_scheduler;
		std::vector<task::const_ptr>   m_tasks;
	};
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
